feat(premium-analytics): expose initial_full_sync_finished on sync status response#49602
feat(premium-analytics): expose initial_full_sync_finished on sync status response#49602chihsuan wants to merge 1 commit into
Conversation
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 Follow this PR Review Process:
If you have questions about anything, reach out in #jetpack-developers for guidance! |
Code Coverage SummaryCoverage changed in 1 file.
|
There was a problem hiding this comment.
Pull request overview
This PR enhances the Premium Analytics sync milestone exposure by injecting the persisted initial_full_sync_finished timestamp into Jetpack core’s existing GET /jetpack/v4/sync/status REST response, enabling consumers (e.g., the analytics dashboard) to observe the milestone flipping mid-session via the existing polling mechanism.
Changes:
- Add a
rest_post_dispatchfilter inSync_Status_Trackerto appendinitial_full_sync_finishedto successful/jetpack/v4/sync/statusresponses. - Extend PHPUnit coverage to validate enrichment behavior (correct route only, skips error responses, passthrough for non-REST responses).
- Add a changelog entry documenting the new REST response field.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| projects/packages/premium-analytics/src/Sync/class-sync-status-tracker.php | Adds REST response enrichment for /jetpack/v4/sync/status with the milestone timestamp. |
| projects/packages/premium-analytics/tests/php/Sync/Sync_Status_Tracker_Test.php | Adds unit tests covering the new REST enrichment behavior and hook registration. |
| projects/packages/premium-analytics/changelog/wooa7s-1542-expose-sync-milestone-live | Documents the new initial_full_sync_finished field on the sync status REST response. |
Related to WOOA7S-1542. Backend half; the frontend consumer (#49267) stacks on top.
Proposed changes
Why: The analytics dashboard reads the initial-full-sync milestone (
jetpack_premium_analytics_initial_full_sync_finished) to know when the first analytics sync has completed. TodaySync_Status_Trackersurfaces it only once, at page load, viaJetpackScriptData— a static snapshot that can't reflect a sync finishing mid-session.How: A
rest_post_dispatchfilter inSync_Status_Trackerappends the milestone to Jetpack core's existingGET /jetpack/v4/sync/statusresponse. No new endpoint and no Jetpack-core changes — the field rides along on the poll the dashboard already makes. Only the already-authorized, successful status payload is touched; other routes and error responses pass through untouched (no milestone leak).What:
GET /jetpack/v4/sync/statusnow includes aninitial_full_sync_finishedinteger (0until the analytics initial full sync completes, then the finish timestamp). Additive and standalone — no consumer in this PR (same split as the PHP/JS halves #49211 / #49267).Does this pull request change what data or activity we track or use?
No.
Testing instructions
On a Jetpack-connected site with the package active:
GET /jetpack/v4/sync/statusnow includes aninitial_full_sync_finishedinteger.POST /jetpack/v4/sync/full-sync) and unauthorized/error responses are unaffected.